//审批提醒
$(function () {
    createTask();
})

function createTask(){
    var options = {
        url: $.webPath() + "/sfgl/fksh/dbsfrwList",
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        fit: true,
        rownumbers: true
    };

    var columns = {columns: [
        [
//            {field: 'id', type:'hidden'},
            {field: 'MC', title: '名称', width: 50, formatter: formatTaskName},
            {field: 'DQZT', title: '状态', width: 60},
            {field: 'TJR', title: '提交人', width: 30},
            {field: 'CJRQ', title: '时间', width: 40},
            {field: 'SKBM', title: '收款编码', width: 30},
            {field: 'FKBM', title: '付款编码', width: 30}
        ]
    ]}
    options = $.extend(options, columns);
    $('#dbsfrw-grid').datagrid(options);
}

function formatTaskName(val,row) {
    var s =  '<a href="javascript:popTaskWindow(\''+row["ID"]+'\');" style="color: red">'+row["MC"]+'</a>';
    return s;
}

function popTaskWindow(id) {
    var detailwin = $.window({
        iconCls: 'icon-add2',
        title: '内部划转收款审核',
        url: $.webPath() + '/sfgl/sksh/sh_nbhz?skshId=' + id,
        width:620,
        height:360,
        modal: true,
        isMax: false,
        buttons: [
            {text: '审核',
                handler:function () {
                    $(detailwin).mask();
                    $('#form_sh_nbhz').form('submit', {
                        onSubmit:function () {
                            $("[name='sksh.zt']").val("ysh");
                            var isValid = $(this).form('validate');
                            if (!isValid) {
                                $(detailwin).mask('hide');
                                return false;
                            }
                            return isValid;
                        },
                        success:function (data) {
                            $(detailwin).mask('hide');
                            var json = $.parseJSON(data);
                            if (json.statusCode == 200) {
                                $(detailwin).window('close');
                                $('#dbsfrw-grid').datagrid('reload');
                                $.messager.show({
                                    title:'提示',
                                    msg:json.message,
                                    timeout:3000,
                                    showType:'slide'
                                });
                            } else
                                $.messager.alert('提示', json.message, 'error');
                        }
                    });
                }}
        ]
    });
}
